package com.mdxl.controller;

import com.mdxl.Entity.Account;
import com.mdxl.dao.note.MbAccountDao;
import com.mdxl.service.AccountService;
import com.mdxl.service.SecondService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.persistence.Cacheable;

/**
 * Created by chengjian on 2017/9/12.
 */
@RestController
@RequestMapping("/mdxl")
public class AccountController {

    private static final Logger logger = LoggerFactory.getLogger(AccountController.class);
    @Autowired
    private AccountService accountService;
    @Autowired
    private SecondService secondService;
    @Autowired
    private  MbAccountDao accountDao;

    @RequestMapping(value = "/insertAccount",method = RequestMethod.POST)
    public void insertAccount(){
        Account account =new Account();
        account.setMoney(123);
        account.setName("76521");
        accountService.insertAccount(account);
    }
    @RequestMapping(value = "/updateAccountXml",method = RequestMethod.POST)
    public void updateAccountXml(){
        Account account =new Account();
        account.setName("chengjian");
        account.setMoney(7872.0);
        accountService.updateAccountXml(account);
    }
    @RequestMapping(value = "/addSecond",method = RequestMethod.POST)
    public void addAcc(){
        Account account =new Account();
        account.setName("第一个");
        account.setMoney(7872.0);
       accountDao.insertAccount(account);
    }
    //分页
    @RequestMapping(value = "/ooa/{page}/{num}",method = RequestMethod.GET,produces = "json/application")
    public Object getListAccount(@PathVariable("page")int page,@PathVariable("num")int num){
        Object list = accountService.getAccountList(page,num);
        return list;
    }
    @RequestMapping(value = "/gain/{id}",method = RequestMethod.GET,produces = "application/json")
    public Account gain(@PathVariable("id")String id){
        return accountService.getAccount(id);
    }
}
